//
//  KAPlanViewController.m
//  KeepAccounts
//
//  Created by honeyrr on 2017/10/30.
//  Copyright © 2017年 honeyrr. All rights reserved.
//

#import "KAPlanViewController.h"
#import "KAPieChartView.h"

@interface KAPlanViewController ()<UIPickerViewDelegate, UIPickerViewDataSource>

@property (weak, nonatomic) IBOutlet UILabel *typeLabel;
@property (weak, nonatomic) IBOutlet UITextField *planMoney;
@property(nonatomic, strong) UIPickerView *pickView;
@property(nonatomic, assign) BOOL isChange;
@property(nonatomic, strong) NSArray *pickArr;
@property(nonatomic, strong) UIButton *button;

@end

@implementation KAPlanViewController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"资产计划";
    self.pickArr = @[@"每月", @"每季度", @"每年"];
    _button = [[UIButton alloc]initWithFrame:CGRectMake(0, KAScreenH - 136, KAScreenW, 36)];
    [_button setTitle:@"确定" forState:UIControlStateNormal];
    _button.titleLabel.textAlignment = NSTextAlignmentLeft;
    [_button setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
    [_button setTitleColor:KANavTabColor forState:UIControlStateNormal];
    _button.hidden = YES;
    [self.view addSubview:_button];
    [_button addTarget:self action:@selector(selectType) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.pickView];
    
    
}

-(void) selectType
{
    self.pickView.hidden = YES;
    self.button.hidden = YES;
    self.isChange = false;
}

-(UIPickerView *)pickView
{
    if (!_pickView) {
        _pickView = [[UIPickerView alloc]initWithFrame:CGRectMake(0,  KAScreenH - 100, KAScreenW, 100)];
        _pickView.delegate = self;
        _pickView.dataSource = self;
        _pickView.hidden = YES;
    }
    return _pickView;
}

- (IBAction)typeChange:(id)sender {
    if (self.isChange) {
        self.pickView.hidden = YES;
        self.button.hidden = YES;
    } else {
        self.pickView.hidden = NO;
        self.button.hidden = NO;
    }
    self.isChange = !self.isChange;
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return self.pickArr.count;
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return self.pickArr[row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    self.typeLabel.text = self.pickArr[row];
}
@end
